// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    msg: "",
   isShow: false,
   btnShow: true,
   num: 15,
   num2: 300000,
  },
  onLoad(options){
    console.log(options.type)
    if(options.type=='easy'){
      this.setData({
        num2:300000
      })
    }else if(options.type=='simple'){
      this.setData({
        num2:450000
      })
    }
  },
  startDo:function(){
    console.log(this.data.num2)
    let that = this
    wx.showModal({
      title: 'Tips',
      content: '"是否决定开始这次激情之旅"',
      success (res) {
        if (res.confirm) {
          that.setData({
            msg:"动起来吧！！！老北鼻",
            isShow :true,
            btnShow: false
          })
        } else if (res.cancel) {
          wx.redirectTo({
            url: '../action/action',
          })
        }
      },
    })
    let timer = setInterval(() => {
      let newNum = this.data.num;
      newNum--;
      this.setData({
        num: newNum,
      })
      if(newNum==0){
        this.setData({
          num: 15
        })
      }
    }, 1000)
    setTimeout(() => {

      clearInterval(timer);
      this.setData({
        msg: "恭喜你完成挑战",
        isShow:false,
      })
    }, that.data.num2)
  },

  
})





